﻿using LCL.LogNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LCL
{
    public class Logger
    {
        private static object _lock = new object();
        private static LogNetBase _impl = new LogNetFileSize();
        public static void SetImplementation(LogNetBase loggerImpl)
        {
            _impl = loggerImpl;
        }
        public static void Info(string message)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Info(message);
                    System.Diagnostics.Trace.WriteLine(message);
                }
                catch { }
            }
        }
        public static void Info(string keyWord, string text)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Info(keyWord, text);
                }
                catch { }
            }
        }
        public static void Warn(string message)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Warn(message);
                }
                catch { }
            }
        }
        public static void Warn(string keyWord, string text)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Warn(keyWord, text);
                }
                catch { }
            }
        }
        public static void Debug(string message)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Debug(message);
                }
                catch { }
            }
        }
        public static void Debug(string keyWord, string text)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Debug(keyWord, text);
                }
                catch { }
            }
        }
        public static void Error(string title)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Error(title, null);
                }
                catch { }
            }
        }
        public static void Error(string keyWord, string text)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Error(keyWord, text);
                }
                catch { }
            }
        }
        public static void Error(string text, Exception ex)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Exception(text, "",ex);
                }
                catch { }
            }
        }
        public static void Exception(string title)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Exception(title, null);
                }
                catch { }
            }
        }
        public static void Exception(string keyWord, string text, Exception ex)
        {
            lock (_lock)
            {
                try
                {
                    _impl.Exception(keyWord, text, ex);
                }
                catch { }
            }
        }
    }
}
